package com.zggk.lzz.seach;


import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;

import com.bigkoo.pickerview.TimePickerView;
import com.zggk.lzz.R;
import com.zggk.lzz.mvp.MVPBaseActivity;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;


/**
 * MVPPlugin
 * 邮箱 784787081@qq.com
 */

public class SeachActivity extends MVPBaseActivity<SeachContract.View, SeachPresenter> implements SeachContract.View {


    @Bind(R.id.back)
    ImageView back;
    @Bind(R.id.title_text)
    TextView titleText;
    @Bind(R.id.cancle_button)
    TextView cancleButton;
    @Bind(R.id.zqmc_et)
    EditText zqmcEt;
    @Bind(R.id.lzxm_et)
    EditText lzxmEt;
    @Bind(R.id.qssj_te)
    TextView qssjTe;
    @Bind(R.id.jssj_te)
    TextView jssjTe;
    @Bind(R.id.activity_disease_new_scrollview)
    ScrollView activityDiseaseNewScrollview;
    @Bind(R.id.cz_te)
    TextView czTe;
    @Bind(R.id.qd_te)
    TextView qdTe;
    @Bind(R.id.disease_new_parent_layout)
    RelativeLayout diseaseNewParentLayout;

    @Override
    public void onRequestError(String msg) {

    }

    @Override
    protected int getLayout() {
        return R.layout.act_seach;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
        initView();
    }

    private void initView() {
        setTitleText("筛选");
        goBack();
        qssjTe.setText(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
        jssjTe.setText(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
    }


    @OnClick({ R.id.qssj_te, R.id.jssj_te, R.id.cz_te, R.id.qd_te})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.qssj_te:
                TimePickerView ksTimes = new TimePickerView.Builder(SeachActivity.this, new TimePickerView.OnTimeSelectListener() {
                    @Override
                    public void onTimeSelect(Date date, View v) {//选中事件回调
                        qssjTe.setText(new SimpleDateFormat("yyyy-MM-dd").format(date));
                    }
                }).setType(new boolean[]{true, true, true, true, true, true})
                        .build();
                ksTimes.setDate(Calendar.getInstance());
                ksTimes.show();
                break;
            case R.id.jssj_te:
                TimePickerView jsTimes = new TimePickerView.Builder(SeachActivity.this, new TimePickerView.OnTimeSelectListener() {
                    @Override
                    public void onTimeSelect(Date date, View v) {//选中事件回调
                        jssjTe.setText(new SimpleDateFormat("yyyy-MM-dd").format(date));
                    }
                }).setType(new boolean[]{true, true, true, true, true, true})
                        .build();
                jsTimes.setDate(Calendar.getInstance());
                jsTimes.show();
                break;
            case R.id.cz_te:
                zqmcEt.setText("");
                lzxmEt.setText("");
                qssjTe.setText(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
                jssjTe.setText(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
                break;
            case R.id.qd_te:
                Intent intent = new Intent();
                intent.putExtra("ZQMC", zqmcEt.getText().toString());
                intent.putExtra("LZXM", lzxmEt.getText().toString());
                intent.putExtra("QSSJ", qssjTe.getText().toString());
                intent.putExtra("JSSJ", jssjTe.getText().toString());
                setResult(2, intent);
                finish();
                break;
        }
    }
}
